package com.songlanyun.modules.rights.dao;

import com.songlanyun.modules.order.model.vo.UserOrderRightsSlimStatisticsVo;
import com.songlanyun.modules.rights.entity.RightsOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.songlanyun.modules.rights.model.dto.KqRefundDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 销售系统中的维权单（前期可能只做统一维权，不过这样不好）
 * 
 * @author lubo
 * @email sunlightcs@gmail.com
 * @date 2020-11-23 13:45:42
 */
@Mapper
public interface RightsOrderDao extends BaseMapper<RightsOrder> {

    UserOrderRightsSlimStatisticsVo loadOrderRightsSlimStatistics(@Param("shopId") Long shopId, @Param("userId") Long userId);

    Integer loadRightsOrderNum(@Param("shopId")Long shopId, @Param("status")Integer status);

    @Select("SELECT\n" +
            "\tyxt_kq_order_0717.order_code AS kqCode,\n" +
            "\tyxt_sale_order.expired,\n" +
            "\tyxt_sale_order.transaction_status AS transactionStatus,\n" +
            "\tyxt_sale_order.pay_mode AS payMode,\n" +
            "\tyxt_sale_order.pay_order_code AS payOrderCode,\n" +
            "\tyxt_sale_order.order_code AS  orderCode,\n" +
            "\tyxt_kq_order_0717.amount \n" +
            "FROM\n" +
            "\tyxt_kq_order_0717\n" +
            "\tLEFT JOIN yxt_sale_order ON yxt_kq_order_0717.order_code = yxt_sale_order.pay_order_code \n" +
            "WHERE\n" +
            "\tyxt_sale_order.transaction_status = 6 \n" +
            "\tAND yxt_sale_order.expired = 1\n" +
            "\tORDER BY yxt_sale_order.create_time ")
    List<KqRefundDTO> getKqRefundInfo();
}
